/*
 * MIT License
 *
 * Copyright (c) 2020 wen.gu <454727014@qq.com>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

/***************************************************************************
 * Name: kfa_render.h
 *
 * Purpose: implementation a render  
 *
 * Developer:
 *   wen.gu , 2022-03-04
 *
 * TODO:
 *
 ***************************************************************************/

/******************************************************************************
 **    INCLUDES
 ******************************************************************************/
#ifndef __KFA_RENDER_H__
#define __KFA_RENDER_H__
#include <string>
#include <stdio.h>
#include <functional>
#include <list>
#include <mutex>
#include <thread>
#include <condition_variable>

#include "kfa_types.h"


/******************************************************************************
 **    MACROS
 ******************************************************************************/

/******************************************************************************
 **    TYPE DEFINITIONS
 ******************************************************************************/
struct render_param
{
    bool repeat = false;
    uint32_t frame_interval_ms = 40;
    int32_t display_id = 1;
    int32_t zorder = 1000;
    int img_width = 1920;
    int img_height = 720;
    /** todo, is need add window size */    
};

struct RenderBuffer
{
    uint8_t* buf_y = nullptr;
    uint8_t* buf_uv = nullptr;
    void* opaque = nullptr;

    std::function<void(RenderBuffer& render_buffer)> release;
};

/******************************************************************************
 **    CLASSES/FUNCTIONS DEFINITIONS
 ******************************************************************************/

class KfaRender
{
public:
    virtual ~KfaRender() = default;
public:
    virtual bool initialize(const render_param& param) = 0;
    virtual bool render(const KfaBuffer& buffer) = 0;
};

#endif /** !__KFA_RENDER_H__ */